using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Text;
using System.Drawing.Imaging;
using Toenda.Rails.Data;
using Toenda.Rails.System;
using Toenda.Rails.DataContainer;
using Toenda.TFL.Drawing;

public partial class Controls_Side_ctrl_actions : System.Web.UI.UserControl {
	private AccountProvider ap = new AccountProvider();
	private ImageProvider ip = new ImageProvider();
	private bool letView = false;
	private bool isLoggedIn = false;
	private Account acc = new Account();
	private Account c = new Account();
	private ServerPath serverpath = new ServerPath();

	/// <summary>
	/// Page_Load
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	protected void Page_Load(object sender, EventArgs e) {
		if(Request.QueryString.Get("user") != null) {
			acc = ap.GetAccountByUsername(Request.QueryString.Get("user").ToString());

			if(Session.Count > 0 
			&& ap.CheckSessionExist(Session["Zappr"].ToString())) {
				c = ap.GetAccountBySession(Session["Zappr"].ToString());

				if(c.ID == acc.ID) {
					isLoggedIn = true;
				}
			}
		}
		else if(Request.QueryString.Get("item") != null) {
			if(ip.CheckImageExists(Request.QueryString.Get("item"))) {
				ImageItem master = ip.GetImage(Convert.ToInt64(Request.QueryString.Get("item")));
				acc = ap.GetAccount(master.UserID);

				if(Session.Count > 0 
				&& ap.CheckSessionExist(Session["Zappr"].ToString())) {
					c = ap.GetAccountBySession(Session["Zappr"].ToString());

					if(c.ID == acc.ID) {
						isLoggedIn = true;
					}
				}
			}
		}
		else if(Session.Count > 0 
		&& ap.CheckSessionExist(Session["Zappr"].ToString())) {
			isLoggedIn = true;
			acc = ap.GetAccountBySession(Session["Zappr"].ToString());
		}

		NameValueCollection sv = Request.ServerVariables;
		
		if(sv["URL"] == "/search.aspx"
		|| sv["URL"] == "/search.aspx"
		|| sv["URL"] == "/WebClient/search.aspx"
		|| sv["URL"] == "/WebClient/search.aspx") {
			plcSets.Visible = false;

			if(Request.QueryString.Get("q") != null) {
				plcSearchActions.Visible = true;

				string q = Request.QueryString.Get("q").ToString();

				// type
				int type = 0;

				if(Request.QueryString.Get("type") == null) {
					type = 0;
				}
				else {
					type = Convert.ToInt32(Request.QueryString.Get("type").ToString());
				}

				linkTagSearch.Text = GetLocalResourceObject("SearchTags").ToString();
				linkTagSearch.NavigateUrl = "~/search.aspx?tag=" + q + "&target=a&type=" + type.ToString();
			}
		}
		else {
			// id
			if(Request.QueryString.Count > 0) {
				switch(Request.QueryString.GetKey(0)) {
					case "id":
						string strID = Request.QueryString.Get("id");

						switch(strID) {
							case "dashboard":
								//if(acc.Type == 0 && acc.UpgradeIsInWork == false) {
								//    this.DisplayDashboardSide(isLoggedIn);
								//}
								this.DisplayDashboardSide(isLoggedIn);
								break;

							case "explore":
								plcDashboard.Visible = false;
								plcSets.Visible = false;
								plcImageTags.Visible = false;
								plcAdditionalInformation.Visible = false;
								break;

							case "profile":
							case "account":
								if(isLoggedIn) {
									plcAccount.Visible = true;
								}

								plcImageTags.Visible = false;
								plcAdditionalInformation.Visible = false;
								break;

							case "images":
								// user profile link
								if(Request.QueryString.Get("user") != null) {
									if(ap.CheckUsernameExist(Request.QueryString.Get("User").ToString())) {
										plcShowProfile.Visible = true;

										//linkUserProfile.NavigateUrl = "~/default.aspx?user="
										//	+ Request.QueryString.Get("user").ToString();
										linkUserProfile.NavigateUrl = "~/user/" + Request.QueryString.Get("user").ToString() + "/default.aspx";

										this.LoadUserStats(acc.ID);
										this.LoadSets();
									}
								}
								break;

							case "sets":
								break;

							case "upload":
								plcUpload.Visible = true;

								if(acc.Type == 0 && acc.UpgradeIsInWork == false) {
									this.DisplayDashboardSide(isLoggedIn);
								}
								else {
									plcBreakUpl.Visible = false;
								}
								
								this.LoadUserUploadStats();
								break;

							default:
								this.DisplayDashboardSide(isLoggedIn);
								break;
						}
						break;

					case "item":
						plcSets.Visible = false;

						plcImageTags.Visible = true;
						plcAdditionalInformation.Visible = true;

						plcShowProfile.Visible = true;
						plcInSet.Visible = true;

						if(ip.CheckImageExists(Request.QueryString.Get("item"))) {
							this.LoadUserStats(acc.ID);
							this.LoadTagsAndImageInformation();
						}
						break;

					case "set":
						this.DisplayDashboardSide(isLoggedIn);
						break;

					case "user":
						if(isLoggedIn && acc.Username == Request.QueryString.Get("user")) {
							plcAccount.Visible = true;
						}

						plcImageTags.Visible = false;
						plcAdditionalInformation.Visible = false;
						break;

					default:
						plcDashboard.Visible = false;
						plcSets.Visible = false;
						plcImageTags.Visible = false;
						plcAdditionalInformation.Visible = false;
						plcSearchActions.Visible = false;
						break;
				}
			}
			else {
				this.DisplayDashboardSide(isLoggedIn);
			}
		}
	}

	/// <summary>
	/// Display the dashboard sidebar
	/// </summary>
	/// <param name="isLoggedIn"></param>
	private void DisplayDashboardSide(bool isLoggedIn) {
		plcDashboard.Visible = true;

		if(isLoggedIn) {
			plcIsLoggedActions.Visible = true;
			plcLoginActions.Visible = false;

			//if(acc.Type == 0 && acc.UpgradeIsInWork == false) {
			//    HyperLink upgrade = new HyperLink();
			//    upgrade.CssClass = "sideActions";
			//    upgrade.Text = GetLocalResourceObject("UpgradeNow").ToString();
			//    //upgrade.NavigateUrl = "~/default.aspx?id=upgrade";
			//    upgrade.NavigateUrl = "~/upgrade/default.aspx";

			//    plcIsLoggedActions.Controls.Add(new LiteralControl("&raquo; "));
			//    plcIsLoggedActions.Controls.Add(upgrade);
			//    plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));
			//    plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));
			//}

			// advise zappr
			HyperLink advise = new HyperLink();
			advise.CssClass = "sideActions";
			advise.Text = GetLocalResourceObject("AdviseZappr").ToString();
			//advise.NavigateUrl = "~/default.aspx?id=advise";
			advise.NavigateUrl = "~/advise/default.aspx";

			plcIsLoggedActions.Controls.Add(new LiteralControl("&raquo; "));
			plcIsLoggedActions.Controls.Add(advise);
			plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));

			// my photos
			HyperLink photos = new HyperLink();
			photos.CssClass = "sideActions";
			photos.Text = GetLocalResourceObject("MyPhotos").ToString();
			//photos.NavigateUrl = "~/default.aspx?id=images&user=" + acc.Username;
			photos.NavigateUrl = "~/images/" + acc.Username + "/default.aspx";

			plcIsLoggedActions.Controls.Add(new LiteralControl("&raquo; "));
			plcIsLoggedActions.Controls.Add(photos);
			plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));

			// upload
			HyperLink upload = new HyperLink();
			upload.CssClass = "sideActions";
			upload.Text = GetLocalResourceObject("UploadText").ToString();
			//upload.NavigateUrl = "~/default.aspx?id=upload";
			upload.NavigateUrl = "~/upload/default.aspx";

			plcIsLoggedActions.Controls.Add(new LiteralControl("&raquo; "));
			plcIsLoggedActions.Controls.Add(upload);
			plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));
			plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));

			// delicious
			System.Web.UI.WebControls.Image delimg = new System.Web.UI.WebControls.Image();
			delimg.ImageUrl = "~/App_Themes/Default/Images/addToDelicious.gif";

			HyperLink delicious = new HyperLink();
			delicious.CssClass = "sideActions paddLeft";
			delicious.Text = GetLocalResourceObject("AddToDelicious").ToString();
			delicious.NavigateUrl = "http://del.icio.us/post/";
			delicious.Target = "_blank";

			plcIsLoggedActions.Controls.Add(new LiteralControl("&raquo; "));
			plcIsLoggedActions.Controls.Add(delimg);
			plcIsLoggedActions.Controls.Add(delicious);
			plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));

			// mr. wong
			System.Web.UI.WebControls.Image mrwimg = new System.Web.UI.WebControls.Image();
			mrwimg.ImageUrl = "~/App_Themes/Default/Images/mr-wong.png";

			HyperLink mrwong = new HyperLink();
			mrwong.CssClass = "sideActions paddLeft";
			mrwong.Text = GetLocalResourceObject("AddToMrWong").ToString();
			mrwong.NavigateUrl = "http://www.mister-wong.de/add_url/";
			mrwong.Target = "_blank";

			plcIsLoggedActions.Controls.Add(new LiteralControl("&raquo; "));
			plcIsLoggedActions.Controls.Add(mrwimg);
			plcIsLoggedActions.Controls.Add(mrwong);
			//plcIsLoggedActions.Controls.Add(new LiteralControl("<br />"));
		}

		plcSets.Visible = false;
		plcImageTags.Visible = false;
		plcAdditionalInformation.Visible = false;

		plcSearchActions.Visible = false;
	}

	/// <summary>
	/// Load sets
	/// </summary>
	private void LoadSets() {
		Account puser = ap.GetAccountByUsername(Request.QueryString.Get("user").ToString());

		List<SetItem> list = ip.GetUserSets(
			puser.ID,
			true      // with images
		);

		if(list != null) {
			if(list.Count > 0) {
				plcSets.Visible = true;

				Panel psets = new Panel();
				psets.Style.Add("text-align", "center");
				int count = 0;
				int imgCount = 0;

				foreach(SetItem set in list) {
					if(count < 10) {
						// thumbnail
						Panel pimg = new Panel();
						pimg.CssClass = "SetCase";

						if(set.Thumbnail != -1) {
							ImageItem mainimg = ip.GetImage(Convert.ToInt64(set.Thumbnail));

							HyperLink thumb = new HyperLink();

							//thumb.NavigateUrl = "~/default.aspx?set=" + set.SetID.ToString();
							thumb.NavigateUrl = "~/set/" + set.SetID.ToString() + "/default.aspx";
							thumb.ImageUrl = "~/Images/" + mainimg.Image75x75;
							thumb.Style.Add("border", "1px solid #eee");
							//thumb.Style.Add("position", "absolute");
							//thumb.Style.Add("margin-left", "7px");

							pimg.Controls.Add(thumb);
						}

						psets.Controls.Add(pimg);

						// name
						HyperLink slink = new HyperLink();
						slink.CssClass = "sideLinks";
						//slink.NavigateUrl = "~/default.aspx?set=" + set.SetID.ToString();
						slink.NavigateUrl = "~/set/" + set.SetID.ToString() + "/default.aspx";
						slink.Text = set.Name;
						//slink.Style.Add("text-align", "left");
						//slink.Style.Add("margin-left", "5px");

						psets.Controls.Add(slink);

						if(isLoggedIn && puser.ID == acc.ID) {
							HyperLink change = new HyperLink();
							change.CssClass = "sideLinks";
							change.Text = GetLocalResourceObject("Change").ToString();
							change.NavigateUrl = "~/default.aspx?id=_editset&set=" + set.SetID.ToString();

							psets.Controls.Add(new LiteralControl(" ("));
							psets.Controls.Add(change);
							psets.Controls.Add(new LiteralControl(")"));
						}

						imgCount = set.Images.Count;

						psets.Controls.Add(new LiteralControl("<br />"));

						Label lblAmount = new Label();
						lblAmount.CssClass = "txtSmallDarkGray";
						lblAmount.Text = imgCount.ToString() + " ";

						if(imgCount == 1) {
							lblAmount.Text += GetLocalResourceObject("Photo").ToString();
						}
						else {
							lblAmount.Text += GetLocalResourceObject("Photos").ToString();
						}

						psets.Controls.Add(lblAmount);
						psets.Controls.Add(new LiteralControl("<br /><br />"));
					}

					count++;
				}

				if(list.Count > 10) {
					HyperLink link = new HyperLink();
					link.CssClass = "sideLinks";
					link.Text = GetLocalResourceObject("LinkToSets").ToString();
					link.NavigateUrl = "~/sets/" + puser.Username + "/default.aspx";

					psets.Controls.Add(new LiteralControl("<br />"));
					psets.Controls.Add(link);
				}

				plcSet.Controls.Add(psets);
			}
		}
	}

	/// <summary>
	/// load additional information and tags
	/// </summary>
	private void LoadTagsAndImageInformation() {
		if(Request.QueryString.Get("item") != null) {
			ImageItem item = ip.GetImage(Convert.ToInt64(Request.QueryString.Get("item")));
			Account user = ap.GetAccount(item.UserID);
			Account chk = new Account();

			if(isLoggedIn) {
				chk = ap.GetAccountBySession(Session["Zappr"].ToString());
			}

			// user profile link
			linkUserProfile.NavigateUrl = "~/default.aspx?user=" + user.Username;

			// check privacy
			if(isLoggedIn) {
				if(item.Access > 0) {
					// this time: only the user itself
					// next time: friends and family
					if(item.UserID == user.ID)
						letView = true;
				}
				else
					letView = true;
			}
			else {
				if(item.Access == 0)
					letView = true;
			}

			// display info
			if(letView) {
				/*
				 * set info
				 */

				List<SetItem> list = ip.GetSetsByImageID(item.ID);

				if(list != null) {
					if(list.Count > 0) {
						// list start
						Literal litbl = new Literal();
						litbl.Text = "<ul class=\"sideBulletList\">";

						plcSetList.Controls.Add(litbl);

						// sets
						foreach(SetItem set in list) {
							if(isLoggedIn) {
								if(user.ID == chk.ID) {
									Literal lin = new Literal();
									lin.Text = "<li>";
									lin.Text += "<a class=\"sideActions\" href=\"/set/" + set.SetID.ToString() + "/default.aspx\">";
									//lin.Text += "<a class=\"sideActions\" href=\"default.aspx?set=" + set.SetID.ToString() + "\">";
									lin.Text += set.Name;
									lin.Text += "</a>";

									Literal lin2 = new Literal();
									lin2.Text = "</li>";

									LinkButton lidel = new LinkButton();
									lidel.CssClass = "sideActions";
									lidel.Text = GetLocalResourceObject("Delete").ToString();
									lidel.Command += new CommandEventHandler(btnDelete_Click);
									lidel.CommandName = "btnDelete_Click";
									lidel.CommandArgument = set.ID + "$" + item.ID + "$" + item.ImageID.ToString();

									plcSetList.Controls.Add(lin);
									plcSetList.Controls.Add(new LiteralControl(" ("));
									plcSetList.Controls.Add(lidel);
									plcSetList.Controls.Add(new LiteralControl(")"));
									plcSetList.Controls.Add(lin2);
								}
							}
							else {
								Literal li = new Literal();
								li.Text = "<li>";
								//li.Text += "<a class=\"sideActions\" href=\"default.aspx?set=" + set.SetID.ToString() + "\">";
								li.Text += "<a class=\"sideActions\" href=\"/set/" + set.SetID.ToString() + "/default.aspx\">";
								li.Text += set.Name;
								li.Text += "</a>";
								li.Text += "</li>";

								plcSetList.Controls.Add(li);
							}
						}

						// list end
						Literal litblClose = new Literal();
						litblClose.Text = "</ul>";

						plcSetList.Controls.Add(litblClose);
					}
					else {
						plcInSet.Visible = false;
					}
				}
				else {
					plcInSet.Visible = false;
				}

				//
				//
				//

				string info = "";

				/*
				 * tags
				 */
				plcTags.Controls.Add(new LiteralControl("<ul class=\"sideBulletList\">"));

				foreach(TagItem tag in item.Tags) {
					//info = "<a href=\"/default.aspx?id=images&user=";
					//info += user.Username;
					//info += "&tag=" + tag.Tag;
					//info += "\" class=\"sideActions\">";
					//info += tag.Tag;
					//info += "</a>";
					info = "<a href=\"/images/";
					info += user.Username;
					info += "/tag/" + tag.Tag;
					info += "/default.aspx";
					info += "\" class=\"sideActions\">";
					info += tag.Tag;
					info += "</a>";

					Literal l1 = new Literal();
					l1.Text = "<li>";
					l1.Text += info;
					l1.Text += "</li>";

					plcTags.Controls.Add(l1);
				}

				plcTags.Controls.Add(new LiteralControl("</ul>"));

				info = "";

				if(isLoggedIn && item.UserID == acc.ID) {
					plcAddTags.Visible = true;
					linkAddTags.NavigateUrl = "~/default.aspx?id=_addtags&photo=" + item.ImageID.ToString();
				}

				/*
				 * additional info
				 */
				lblPrivacyLoaded.Text = " " + (item.Access == 0
					? GetLocalResourceObject("Public").ToString()
					: GetLocalResourceObject("Private").ToString());

				ExifReader ew = new ExifReader(
					this.serverpath.Path + @"\Images\" + item.ImageOriginal
				);

				// save the exif data to db
				if(item.EquipmentMaker == null
				|| item.EquipmentMaker.Trim() == ""
				|| item.EquipmentModel == null
				|| item.EquipmentModel.Trim() == "") {
					item.EquipmentMaker = ew.EquipmentMaker;
					item.EquipmentModel = ew.EquipmentModel;

					this.ip.SaveImage(item);
				}

				// list start
				plcInfo.Controls.Add(new LiteralControl("<ul class=\"sideBulletList\">"));

				if(ew.EquipmentMaker != "" && ew.EquipmentMaker != null) {
					info += GetLocalResourceObject("ShotWith").ToString();
					info += " ";
					info += ew.EquipmentMaker;
				}

				if(ew.EquipmentModel != "" && ew.EquipmentModel != null) {
					if(info != "")
						info += " ";

					info += ew.EquipmentModel;
				}

				if(info != "") {
					Literal litTextCamera = new Literal();
					litTextCamera.Text = "<li>";
					litTextCamera.Text += info;
					litTextCamera.Text += "</li>";

					plcInfo.Controls.Add(litTextCamera);
				}

				// shot on
				info = "";

				info += GetLocalResourceObject("ShotOn").ToString();
				info += " ";
				info += ew.DateTimeOriginal.ToLongDateString();

				Literal litTextDateTime = new Literal();
				litTextDateTime.Text = "<li>";
				litTextDateTime.Text += info;
				litTextDateTime.Text += "</li>";

				plcInfo.Controls.Add(litTextDateTime);

				// upload date
				Literal litTextUploadDate = new Literal();
				litTextUploadDate.Text = "<li>";
				litTextUploadDate.Text += GetLocalResourceObject("UploadedOn").ToString();
				litTextUploadDate.Text += " ";
				litTextUploadDate.Text += item.UploadDate.ToLongDateString();
				litTextUploadDate.Text += "</li>";

				plcInfo.Controls.Add(litTextUploadDate);

				// amount of views
				long views = ip.GetImageViewAmount(item.ID);

				Literal litTextViews = new Literal();
				litTextViews.Text = "<li>";
				litTextViews.Text += views.ToString();
				litTextViews.Text += " ";
				litTextViews.Text += GetLocalResourceObject("Views").ToString();
				litTextViews.Text += "</li>";

				plcInfo.Controls.Add(litTextViews);

				// action: edit something
				if(isLoggedIn) {
					if(user.ID == chk.ID) {
						Literal litEditLI = new Literal();
						litEditLI.Text = "<li>";

						plcInfo.Controls.Add(litEditLI);

						HyperLink linkEdit = new HyperLink();
						linkEdit.CssClass = "sideActions";
						linkEdit.NavigateUrl = "~/default.aspx?id=_edit&photo="
							+ item.ImageID.ToString();
						linkEdit.Text = GetLocalResourceObject("Edit").ToString();

						plcInfo.Controls.Add(linkEdit);

						Literal litEdit = new Literal();
						litEdit.Text = " " + GetLocalResourceObject("SomeInfo").ToString();

						plcInfo.Controls.Add(litEdit);

						Literal litEditLIClose = new Literal();
						litEditLIClose.Text = "</li>";

						plcInfo.Controls.Add(litEditLIClose);
					}
				}

				// list end
				plcInfo.Controls.Add(new LiteralControl("</ul>"));
				plcInfo.Controls.Add(new LiteralControl("<br />"));

				// link more
				LinkButton linkCompleteEXIF = new LinkButton();
				linkCompleteEXIF.CssClass = "sideActions";
				linkCompleteEXIF.Text = GetLocalResourceObject("CompleteEXIF").ToString();
				linkCompleteEXIF.PostBackUrl = "~/exif/photo/" + item.ImageID.ToString() + "/default.aspx";

				plcInfo.Controls.Add(linkCompleteEXIF);

				// list end
				plcInfo.Controls.Add(new LiteralControl("<br />"));
			}
		}
	}

	/// <summary>
	/// Load user stats
	/// </summary>
	/// <param name="userid"></param>
	private void LoadUserStats(string userid) {
		int amount = ip.GetImageAmount(userid);

		BulletedList bl = new BulletedList();
		bl.CssClass = "sideBulletList";
		bl.Items.Add(
			new ListItem(
				amount.ToString()
				+ " "
				+ GetLocalResourceObject("Photos").ToString()
			)
		);

		long vamount = ip.GetUserViewAmount(userid);
		bl.Items.Add(
			new ListItem(
				vamount.ToString()
				+ " "
				+ GetLocalResourceObject("Views").ToString()
			)
		);

		plcUserInfo.Controls.Add(bl);

		lblProfileTitle.Text = acc.Username;
		lblProfileTitle.Text += "'s ";
		lblProfileTitle.Text += GetLocalResourceObject("Profile").ToString();

		lblSetsTitle.Text = acc.Username;
		lblSetsTitle.Text += "'s ";
		lblSetsTitle.Text += GetLocalResourceObject("Sets").ToString();
	}

	/// <summary>
	/// Load the upload stats fo a user
	/// </summary>
	private void LoadUserUploadStats() {
		if(Session.Count > 0 && ap.CheckSessionExist(Session["Zappr"].ToString())) {
			Account acc = ap.GetAccountBySession(Session["Zappr"].ToString());

			Panel up = new Panel();
			up.CssClass = "uploadStatBox";
			up.Style.Add("text-align", "center");

			plcUploadCounter.Controls.Add(up);

			Label thismonth = new Label();
			thismonth.Text = GetLocalResourceObject("UploadedThisMonth").ToString();
			thismonth.Text += " (";
			thismonth.Text += GetLocalResourceObject("max").ToString();
			thismonth.Text += " ";
			thismonth.Text += acc.MaxStorageMB.ToString();
			thismonth.Text += " MB)";
			thismonth.Text += ":<br /><br />";

			up.Controls.Add(thismonth);

			// get amount
			double max = Convert.ToDouble(acc.MaxStorageMB);
			double amount = ap.GetUsersUploadedMB(acc.ID);

			if(amount > 0) {
				amount = amount / (max / 100);
			}

			amount = System.Math.Round(amount, 2);

			Label amountmb = new Label();
			amountmb.CssClass = "txtH1";
			amountmb.Text = amount.ToString();
			amountmb.Text += " %";

			up.Controls.Add(amountmb);

			up.Controls.Add(new LiteralControl("<br /><br />"));
		}
	}

	/// <summary>
	/// Event for delete a image from a set
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	protected void btnDelete_Click(object sender, CommandEventArgs e) {
		char[] seperator = new char[1];
		seperator[0] = '$';
		string[] spliter = e.CommandArgument.ToString().Split(seperator);

		ip.DeleteImageFromSet(spliter[1], spliter[0]);

		Response.Redirect("~/default.aspx?item=" + spliter[2]);
	}
}
